package com.sharemarking.wa.platform.mapper;

import com.sharemarking.wa.platform.dto.cms.CmsChannelListDto;
import com.sharemarking.wa.platform.dto.cms.CmsPostInfoDto;
import com.sharemarking.wa.platform.dto.cms.CmsPostListDto;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author dxy
 */
@Repository
public interface CmsMapper {
    @Select("SELECT id AS channelId,display_name AS name FROM cms_channel WHERE parent = 1 ORDER BY sort LIMIT 5,11")
    List<CmsChannelListDto> getMostNesChannelList();

    @Select("SELECT id AS articleId,cover AS pic,title,publish_time FROM cms_post WHERE channel_id = #{channelId} AND hidden = 0 ORDER BY publish_time DESC LIMIT #{pageIndex},#{pageSize}")
    List<CmsPostListDto> getCmsPostList(Map map);

    @Select("SELECT COUNT(*) FROM cms_post WHERE channel_id = #{channelId}")
    Integer getCmsPostTotal(Map map);

    @Select("SELECT id AS articleId,title,content,publish_time FROM cms_post WHERE id = #{articleId}")
    CmsPostInfoDto getCmsPostInfo(Integer articleId);
}
